<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增消息通知配置')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-triggers-add">
            <input name="newsNodeId" type="hidden" id="newsNodeId">
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">归属节点：</label>
                <div class="col-sm-8">
                    <div class="input-group">
                        <input name="treeName" onclick="selectNodeTree()" id="treeName" type="text" placeholder="请选择归属节点" class="form-control" required>
                        <span class="input-group-addon"><i class="fa fa-search"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">消息类型：</label>
                <div class="col-sm-8">
                    <div class="radio-box" th:each="dict : ${@dict.getType('sys_news_type')}">
                        <input type="radio" th:id="${dict.dictCode}" name="newsType" th:value="${dict.dictValue}" th:checked="${dict.default}">
                        <label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
                    </div>
                </div>
            </div>
          <!--  <div class="form-group">
                <label class="col-sm-3 control-label">消息开关：</label>
                <div class="col-sm-8">
                    <input name="newsOnOff" class="form-control" type="text">
                </div>
            </div>-->
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: ztree-js" />
    <script th:inline="javascript">
        var prefix = ctx + "system/triggers";
        $("#form-triggers-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-triggers-add').serialize());
            }
        }


        /*消息配置节点-新增-选择父部门树*/
        function selectNodeTree() {
            var treeId = $("#treeId").val();
            var deptId = $.common.isEmpty(treeId) ? "100" : $("#treeId").val();
            var options = {
                title: '消息配置节点选择',
                width: "380",
                url:ctx + "system/node/selectTriggerTree/" + deptId,
                callBack: doSubmit
            };
            $.modal.openOptions(options);
        }


        function doSubmit(index, layero){
            var body = layer.getChildFrame('body', index);
            var treeName= body.find('#treeName').val();
            if($.common.isEmpty(treeName)){
                $.modal.msgError("请选择子节点后再提交");
                return false;
            }
            $("#treeId").val(body.find('#treeId').val());
            $("#newsNodeId").val(body.find('#treeId').val());
            $("#treeName").val(body.find('#treeName').val());
            layer.close(index);
        }
    </script>
</body>
</html>